defimpl Jason.Encoder, for: [
  ProgContest.Contests.Contest,
  ProgContest.Quizzes.Quiz,
  ProgContest.DockerImages.DockerImage
] do
  def encode(struct, opts) do
    struct
    |> Map.from_struct()
    |> Stream.reject(fn
         {:__meta__, _} -> true
         {_k, %Ecto.Association.NotLoaded{}} -> true
         _ -> false
       end)
    |> Enum.into(%{})
    |> Jason.Encode.map(opts)
  end
end
